<?php

/**
 * @author javier steven jimenez
 */
class VistaBase {
    /*
     * Asigna variable para ser usada en la vista
     */

    function asignarVariable($variable, $valor) {
        $this->$variable = $valor;
    }

    /*
     * Cargar archivo php con html predefinido
     */

    function cargarTemplate($template) {
        $template = strtolower($template);
        $template = 'template/' . $template . '.html';
        if (file_exists($template)) {
            require_once $template;
            return true;
        } else {
            return false;
        }
    }

    /**
     * crear una lista (comboBox)
     * @param type $label 
     * @param type $name
     * @param type $options
     * @param type $value
     * @param type $class_label
     * @param type $class_input
     */
    function crearCombo($label, $name, $options, $value = "", $class_label = "", $class_input = "") {
        ?>
        <div class="<?php echo $class_input ?>">
            <label for="<?php echo $name ?>" class="<?php echo $class_label ?>" ><?php echo $label ?></label>
            <select name="<?php echo $name ?>" id="<?php echo $name ?>"  >
                <?php
                foreach ($options as $valor => $opcion):
                    if ($value == $valor) {
                        $selected = "selected";
                    } else {
                        $selected = "";
                    }
                    ?>
                    <option value="<?php echo $valor ?>" <?php echo $selected ?> ><?php echo $opcion ?></option>
                <?php endforeach; ?>
            </select>
            <div id="error_<?php echo $name ?>"></div>
        </div>
        <?php
    }

    /**
     * Crear capa de pregunta
     * @param type $id
     * @param type $class_label
     */
    function pregunta($id, $class_label = "", $pregunta = "", $comentario = "",$htmlExtra = "") {
        ?>
<section class="ui-selector-pregunta" id="pregunta<?php echo $id ?>">
            <label class="<?php echo $class_label ?>" >Pregunta <?php echo $id ?></label>
            <br>
            <ul>
                <div style="width: 100%">
                    <div style="width: 50%;float: left">
                        <label class="<?php echo $class_label ?>" >Escriba la pregunta</label>
                        <textarea cols="80" id="editPregunta<?php echo $id ?>" name="editPregunta<?php echo $id ?>" rows="10">
                            <?php echo $pregunta ?>
                        </textarea>
                    </div>
                    <div style="width: 50%;float: left">
                        <label class="<?php echo $class_label ?>" >Escriba un comentario (opcional)</label>
                        <textarea cols="80" id="editComentario<?php echo $id ?>" name="editComentario<?php echo $id ?>"  rows="10">
                            <?php echo $comentario ?>
                        </textarea>
                    </div>
                </div>
            </ul>
            <?php echo $htmlExtra ?>
            &nbsp;
        </section>
        
        <script>
            CKEDITOR.replace("editPregunta<?php echo $id ?>", {
                extraPlugins: 'uicolor',
                uiColor: '#48a4cb'
            });
            CKEDITOR.replace("editComentario<?php echo $id ?>", {
                extraPlugins: 'uicolor',
                uiColor: '#48a4cb'
            });


            {
            }
            ;
        </script>
        <?php
    }
    function crearToken(){
        $numero = rand(0, 999999999999);
        $_SESSION["token"] = $numero;
        return $numero;
    }
    function listaCalidadDeUso() {
        $array = array(
            "1" => "Efectividad",
            "2" => "Productividad",
            "3" => "Seguridad",
            "4" => "Satisfacci&oacute;n",
        );
        return $array;
    }

}
?>
